package com.apes.framework.plugin.esb.parser.element;

import com.apes.framework.plugin.esb.parser.node.ChainNodeParser;
import com.apes.framework.plugin.esb.processor.ChainProcessor;
import com.apes.framework.plugin.filereader.xml.ApesElement;
import com.apes.framework.plugin.filereader.xml.ApesElementParser;
import com.apes.framework.util.Tools;

/**
 * 功能：抽象处理器元素解析器
 *
 * @author xul
 * @create 2018-04-21 10:46
 */
public abstract class AbstractProcessorParser implements ApesElementParser<ApesElement, ChainProcessor> {

    /**
     * 功能：可解析节点域
     */
    @Override
    public String getDomain() {
        return ChainNodeParser.domain;
    }

    @Override
    public ChainProcessor parse(ApesElement element) {
        ChainProcessor processor = Tools.toBean(getChainProcessorClass(), element.getAttributes());
        return processor;
    }

    abstract <T extends Class> T getChainProcessorClass();
}
